﻿#if SILVERLIGHT || MONODROID || __IOS__
#define USELEGACYDIALOGS
#endif

#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2010-12-28 21:07:13Z</CreationDate>
</File>
*/
#endregion

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using Outcoder.Services.DialogService;

namespace Outcoder.Services.Implementation
{
	public class MockDialogService : DialogServiceBase
	{
		public object Content { get; set; }
		public string Caption { get; set; }
		public DialogButton DialogButton { get; set; }
		public DialogImage DialogImage { get; set; }
		public DialogImportance? ImportanceThreshold { get; set; }
		public object Details { get; set; }
		
		DialogResult showCustomDialogResult = DialogResult.OK;

		public DialogResult ShowCustomDialogResult
		{
			get
			{
				return showCustomDialogResult;
			}
			set
			{
				showCustomDialogResult = value;
			}
		}

		public override Task<DialogResult> ShowDialogAsync(
			object content, string caption, DialogButton dialogButton,
			DialogImage dialogImage = DialogImage.None,
			DialogImportance importanceThreshold = DialogImportance.High, object details = null,
			DialogController dialogController = null)
		{
			Content = content;
			Caption = caption;
			DialogButton = dialogButton;
			DialogImage = dialogImage;
			ImportanceThreshold = importanceThreshold;
			Details = details;

			return Task.FromResult(showCustomDialogResult);
		}

		TextResponse askQuestionWithTextResponseResult 
			= new TextResponse(OkCancelQuestionResult.Ok, "MockDialogService response.");

		public TextResponse AskQuestionWithTextResponseResult
		{
			get
			{
				return askQuestionWithTextResponseResult;
			}
			set
			{
				askQuestionWithTextResponseResult = value;
			}
		}

		public object TextResponseQuestion { get; set; }
		public object MockResponseResult { get; set; }

		public TextResponse TextResponse { get; set; }

		public int AskQuestionMockResult { get; set; }

		public override Task<int?> ShowDialogAsync(object body, IEnumerable<object> buttons,
									string caption = null,
									int defaultAcceptButtonIndex = -1,
									object expandableDetails = null,
									DialogController dialogController = null)
		{
			int? result = AskQuestionMockResult;
			return Task.FromResult(result);
		}

#if WINDOWS_PHONE || WINDOWS_UWP || __ANDROID__
		public override Task<object> ShowToastAsync(ToastParameters toastParameters)
		{
			TaskCompletionSource<object> source = new TaskCompletionSource<object>();
			source.SetResult(null);
			return source.Task;
		}
#endif
		
		public object AskQuestionMockQuestionResult { get; set; }

		public override Task<QuestionResponse<TResponse>> AskQuestionAsync<TResponse>(IQuestion<TResponse> question)
		{
			return (Task<QuestionResponse<TResponse>>)AskQuestionMockQuestionResult;
		}

		//public async override Task<TextResponse> AskQuestionWithTextResponse(
		//	TextResponseQuestion textResponseQuestion)
		//{
		//	TextResponseQuestion = textResponseQuestion;
		//	return TextResponse;
		//}
	}
}
